The following example demonstrates how to initialize the values of the ShipCountry, ShipCity, and ShipVia columns in an insertion row located in the fixed headers. The handler for the InitializingInsertionRow event is defined in the code-behind class.

The columns that are contained in the grid will be limited to those specified in the ItemProperties of the DataGridCollectionViewSource.

XAML
Copy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">

  <Grid.Resources>

    <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"

                                    Source="{Binding Source={x:Static Application.Current},

                                                        Path=Orders}"

                                    AutoCreateItemProperties="False">

      <xcdg:DataGridCollectionViewSource.ItemProperties>

        <xcdg:DataGridItemProperty Name="ShipCountry" Title="Country"/>

        <xcdg:DataGridItemProperty Name="ShipCity" Title="City"/>

        <xcdg:DataGridItemProperty Name="ShipVia" Title="Ship With"/>

      </xcdg:DataGridCollectionViewSource.ItemProperties>

    </xcdg:DataGridCollectionViewSource>

   </Grid.Resources>



   <xcdg:DataGridControl x:Name="OrdersGrid"

                         ItemsSource="{Binding Source={StaticResource cvs_orders}}"

                         InitializingInsertionRow="InitInsertion">

       <xcdg:DataGridControl.View>

         <xcdg:CardView>

           <xcdg:CardView.FixedHeaders>

              <DataTemplate>

                 <xcdg:InsertionRow/>

              </DataTemplate>

           </xcdg:CardView.FixedHeaders>

         </xcdg:CardView>

      </xcdg:DataGridControl.View>

   </xcdg:DataGridControl>

</Grid> 
VB.NET
Copy Code
Private Sub InitInertion( ByVal sender As Object, ByVal e As InitializingInsertionRowEventArgs )

   e.InsertionRow.Cells( "ShipCountry" ).Content = 

              Me.ParseCountry( System.Globalization.CultureInfo.CurrentCulture.DisplayName )

   e.InsertionRow.Cells( "ShipCity" ).Content = "Enter City Here"

   e.InsertionRow.Cells( "ShipVia" ).Content = 1

End Sub

Private Function ParseCountry( ByVal name As String ) As String

   Dim startIndex As Integer = name.IndexOf( "(" )

   Return name.SubString( startIndex + 1, name.Length - startIndex - 2 )

End Function
C#
Copy Code
private void InitInsertion( object sender, InitializingInsertionRowEventArgs e )

{

   e.InsertionRow.Cells[ "ShipCountry" ].Content = 

         this.ParseCountry( System.Globalization.CultureInfo.CurrentCulture.DisplayName );

   e.InsertionRow.Cells[ "ShipCity" ].Content = "Enter City Here";

   e.InsertionRow.Cells[ "ShipVia" ].Content = "1";

}

private string ParseCountry( string name )

{

   int startIndex = name.IndexOf( "(" );

   return name.Substring( startIndex + 1, name.Length - startIndex - 2 );

}